﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace MasApp.BLL
{
    public class Update
    {
        public Update()
        {
            //
            //TODO: 在此处添加构造函数逻辑
            //
        }
        /// <summary>
        /// 提交levelmission BY Model.levelmission(levelmissionid, state)
        /// </summary>
        /// <param name="lm"></param>
        /// <returns></returns>
        public static int FinishLevelmission(Model.levelmission lm)
        {
            string str = "Update levelmission SET state = '" + lm.State + "'"
                + " WHERE (levelmissionid = " + lm.Levelmissionid + ")";
            return DAL.Update.UpdateINT(str);
        }
        public static int FinishWeightmission(Model.weightmission wm)
        {
            string s = "Update weightmission Set state = '" + wm.State + "'"
                + " Where (weightmissionid = " + wm.Weightmissionid + ")";
            return DAL.Update.UpdateINT(s);
        }
        /// <summary>
        /// 通过Applevle模型（主要是applevelid）返回更新影响行数
        /// </summary>
        /// <param name="appl"></param>
        /// <returns></returns>
        public static int UpdateAppLevelValue(Model.applevel appl)
        {
            return MasApp.DAL.Update.UpdateAppLevelValue(appl);
        }
        /// <summary>
        /// aio.Indicatororder+ aio.Weightmissionid+ aio.Indicatorid 
        /// </summary>
        /// <param name="aio"></param>
        /// <returns></returns>
        public static bool UpdateAppIndicatorOrder(Model.appindicatororder aio)
        {
            string s = "Update appindicatororder Set indicatororder = " + aio.Indicatororder
                + " Where (weightmissionid = " + aio.Weightmissionid + ")"
                + " And (ruleid = " + aio.Indicatorid + ")";
            return DAL.Update.UpdateINT(s) > 0 ? true : false;
        }
        /// <summary>
        /// + aro.Ruleorder + aro.Ruleid
        /// </summary>
        /// <param name="aro"></param>
        /// <returns></returns>
        public static bool UpdateAppRuleOrder(Model.appruleorder aro)
        {
            string s = "Update appruleorder Set ruleorder = " + aro.Ruleorder
                + " Where (weightmissionid = " + aro.Weightmissionid + ")"
                + " And (ruleid = " + aro.Ruleid + ")";
            return DAL.Update.UpdateINT(s) > 0 ? true : false;
        }
        /// <summary>
        /// 通过任务ID更新权重任务状态SET state = '在做的'，返回影响行数
        /// </summary>
        /// <param name="misid"></param>
        /// <returns></returns>
        public static int UpdateWeightMission(int misid)
        {
            return DAL.Update.UpdateWeightMission(misid);
        }
        /// <summary>
        /// 通过任务ID更新等级任务状态，返回影响行数
        /// </summary>
        /// <param name="misid"></param>
        /// <returns></returns>
        public static int UpdateLevelMission(int misid)
        {
            return DAL.Update.UpdateLevelMission(misid);
        }
        /// <summary>
        /// 通过we更新权重值，返回影响行数
        /// </summary>
        /// <param name="we"></param>
        /// <returns></returns>
        public static int UpdateWeight(Model.weight we)
        {
            return DAL.Update.UpdateWeight(we);
        }
        /// <summary>
        /// 更新密码，返回影响行数
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static int UpdatePassword(string username, string password)
        {
            return MasApp.DAL.Update.UpdatePassword(username, password);
        }
        /// <summary>
        /// 提交评估方法
        /// </summary>
        /// <param name="methodid"></param>
        /// <returns></returns>
        public static bool SubmitMethod(int methodid)
        {
            return DAL.Update.SubmitMethod(methodid);
        }
        /// <summary>
        /// 提交模型，返回影响行数
        /// </summary>
        /// <param name="modelid"></param>
        /// <returns></returns>
        public static bool SubmitModel(int modelid)
        {
            return DAL.Update.SubmitModel(modelid);
        }
        /// <summary>
        /// 启动项目，返回成功与否状态
        /// </summary>
        /// <param name="projectid"></param>
        /// <returns></returns>
        public static bool StartProject(int projectid)
        {
            return MasApp.DAL.Update.StartProject(projectid) > 0 ? true : false;
        }
        /// <summary>
        /// 更新项目，返回成功与否状态
        /// </summary>
        /// <param name="pro"></param>
        /// <returns></returns>
        public static bool UpdateProject(Model.project pro)
        {
            return MasApp.DAL.Update.UpdateProject(pro) > 0 ? true : false;
        }
        /// <summary>
        /// 根据projectid AND project.state 更新项目返回影响行数
        /// </summary>
        /// <param name="projectid"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        public static int UpdateProjectState(int projectid, string state)
        {
            string str = "UPDATE project SET state = '" + state + "'"
                + " WHERE (projectid= " + projectid + ")";
            return MasApp.DAL.Update.UpdateINT(str);
        }
    }
}